package com.example.springbootrabbitmq.controller;

import com.example.springbootrabbitmq.callback.CallbackSender;
import com.example.springbootrabbitmq.fanout.FanoutSender;
import com.example.springbootrabbitmq.hello.HelloSender1;
import com.example.springbootrabbitmq.hello.HelloSender2;
import com.example.springbootrabbitmq.topic.TopicSender;
import com.example.springbootrabbitmq.user.UserSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/rabbit")
public class RabbitTestController {

    @Autowired
    private HelloSender1 helloSender1;

    @Autowired
    private HelloSender2 helloSender2;

    @Autowired
    private UserSender userSender;

    @Autowired
    private TopicSender topicSender;

    @Autowired
    private FanoutSender fanoutSender;

    @Autowired
    private CallbackSender callbackSender;

    @GetMapping("/hello")
    public void hello() {
        helloSender1.send("hello1");
    }

    @GetMapping("/oneToMany")
    public void oneToMany() {
        for (int i = 0; i < 10; i++) {
            helloSender1.send("hellomsg:" + i);
        }
    }

    @GetMapping("/manyToMany")
    public void manyToMany() {
        for (int i = 0; i < 10; i++) {
            helloSender1.send("hellomsg:" + i);
            helloSender2.send("hellomsg:" + i);
        }
    }

    @GetMapping("/userTest")
    public void userTest() {
        userSender.send();
    }

    @GetMapping("/topicTest")
    public void topicTest() {
        topicSender.send();
    }

    @GetMapping("/fanoutTest")
    public void fanoutTest() {
        fanoutSender.send();
    }

    @GetMapping("/callback")
    public void callback() {
        callbackSender.send();
    }
}
